<template>

<!--  作业批阅详情-->
  <div class="container" style="width:550px;height: 400px;float: left">
    <div ref="main" style="width:550px;height: 400px;margin-top: 40px"></div>
  </div>
</template>

<script>
export default {
  props:{
    data: {},
  },
  created() {

  },
  mounted() {
    this.initChart()
  },
  methods:{
    initChart() {

      const chartDom = this.$echarts.init(this.$refs.main)
      const option = {
        title: {
          text: '作业批阅详情',
          left: 'center'
        },
        tooltip: {
          trigger: 'item'
        },
        legend: {
          orient: 'vertical',
          left: 'left'
        },
        series: [
          {
            name: 'Access From',
            type: 'pie',
            radius: '50%',
            data: this.data,
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      };

      option && chartDom.setOption(option);


      // 监听饼状图点击事件
      chartDom.on('click', function(params) {
        // 获取被点击项的名称和数值
        var name = params.name;
        var value = params.value;

        // 在控制台输出被点击项的信息
        console.log(name + ' 被点击了，数值为：' + value);
      });

    }
  }
}
</script>

<style scoped>

</style>